<%--
  Created by IntelliJ IDEA.
  User: Doris丶Lee
  Date: 2020-05-20
  Time: 18:35
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="entity.Item"%>
<%@ page import="dao.ItemDao"%>
<%@ page import="java.util.ArrayList" %>
<html>
  <head>
    <title>JspViewListDemo查看商品信息</title>
    <style type="text/css">
      div{
        float:left;
        margin: 10px;
      }
      div dd{
        margin:0px;
        font-size:10pt;
      }
      div dd.dd_name
      {
        color:blue;
      }
      div dd.dd_city
      {
        color:#000;
      }
    </style>
  </head>
  <body>
    <h1>商品展示</h1>
    <hr>

    <div>
      <table width="750" height="60" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td>

            <!-- 商品循环开始 -->
            <%
              ItemDao itemsDao = new ItemDao();
              ArrayList<Item> list = itemsDao.getAllItems();
              if(list!=null&&list.size()>0)
              {
                for(int i=0;i<list.size();i++)
                {
                  Item item = list.get(i);
            %>
            <div>
              <dl>
                <dt>
                  <a href="details.jsp?id=<%=item.getId()%>"><img src="images/<%=item.getPicture()%>" width="120" height="90" border="1"/></a>
                </dt>
                <dd class="dd_name"><%=item.getName() %></dd>
                <dd class="dd_city">产地:<%=item.getCity() %>&nbsp;&nbsp;价格:￥ <%=item.getPrice() %></dd>
              </dl>
            </div>
            <!-- 商品循环结束 -->

            <%
                }
              }
            %>
          </td>
        </tr>
      </table>
    </div>
  </body>
</html>
